package com.py.warehouse.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.py.warehouse.domain.WhCheckDetails;
import com.py.warehouse.service.IWhCheckDetailsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * eeController
 *
 * @author admin
 * @date 2024-12-09
 */
@RestController
@RequestMapping("/details")
public class WhCheckDetailsController extends BaseController
{
    @Autowired
    private IWhCheckDetailsService whCheckDetailsService;

    /**
     * 查询ee列表
     */
    @RequiresPermissions("warehouse:details:list")
    @GetMapping("/list")
    public TableDataInfo list(WhCheckDetails whCheckDetails)
    {
        startPage();
        List<WhCheckDetails> list = whCheckDetailsService.selectWhCheckDetailsList(whCheckDetails);
        return getDataTable(list);
    }

    /**
     * 导出ee列表
     */
    @RequiresPermissions("warehouse:details:export")
    @Log(title = "ee", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WhCheckDetails whCheckDetails)
    {
        List<WhCheckDetails> list = whCheckDetailsService.selectWhCheckDetailsList(whCheckDetails);
        ExcelUtil<WhCheckDetails> util = new ExcelUtil<WhCheckDetails>(WhCheckDetails.class);
        util.exportExcel(response, list, "ee数据");
    }

    /**
     * 获取ee详细信息
     */
    @RequiresPermissions("warehouse:details:query")
    @GetMapping(value = "/{detailsId}")
    public AjaxResult getInfo(@PathVariable("detailsId") Long detailsId)
    {
        return success(whCheckDetailsService.selectWhCheckDetailsByDetailsId(detailsId));
    }

    /**
     * 新增ee
     */
    @RequiresPermissions("warehouse:details:add")
    @Log(title = "ee", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<WhCheckDetails> list)
    {
        list.forEach(wd -> {
            whCheckDetailsService.insertWhCheckDetails(wd);
        });

        return toAjax(list.size());
    }

    /**
     * 修改ee
     */
    @GetMapping
    public AjaxResult edit(@RequestParam("code")String code)
    {

        return toAjax(whCheckDetailsService.updateWhCheckDetails(code));
    }
}
